using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Xml;

namespace Common
{
    public class ConnectManager
    {
        private SqlDataAdapter da;
        public SqlConnection conn;
        String strConnect;

        public ConnectManager()
        {
            XmlManager readXML = new XmlManager();
            strConnect = readXML.readXml();
            conn = new SqlConnection(strConnect);
        }

        public DataSet getDataset(String cmd, String tbName)
        {
            da = new SqlDataAdapter(cmd, conn);
            DataSet ds = new DataSet();
            da.Fill(ds, tbName);
            return ds;
        }

        public DataTable getTable(String cmd)
        {
            da = new SqlDataAdapter(cmd, conn);
            DataSet ds = new DataSet();
            da.Fill(ds);
            DataTable tb = ds.Tables[0];
            return tb;
        }

        public DataTable getTable(String cmd, SqlTransaction trans1)
        {
            da = new SqlDataAdapter(cmd, conn);
            DataSet ds = new DataSet();
            da.SelectCommand.Transaction = trans1;
            da.Fill(ds);
            DataTable tb = ds.Tables[0];
            return tb;
        }

    }
}
